<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.DriverManager" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/5/20
  Time: 0:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    String id  =request.getParameter("id");
    Connection connection=null;
    PreparedStatement statement=null;

    String sql="DELETE from t_users where id=?";
    Class.forName("com.mysql.jdbc.Driver");
    connection= DriverManager.getConnection(
            "jdbc:mysql://localhost:3306/sctu_javaweb_2018?serverTimezone=UTC",
            "root",
            "123456"
    );
    statement=connection.prepareStatement(sql);
    statement.setString(1,id);
    int result=statement.executeUpdate();
    String m="删除失败";
    if (result==1){
        m="删除成功";
    }
    statement.close();
    connection.close();
%>
<script>window.alert('<%=m%>');</script>
<%
    response.setHeader("Refresh","1;url=userList");
%>
</body>
</html>
